package com.x.Part5_String.StringBuilder;

/**
 * ClassName: StringBuilderTest
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.03.15 10:44
 */
public class StringBuilderTest {
    public static void main(String[] args) {
        StringBuilder stringBuilder1 = new StringBuilder();
        StringBuilder stringBuilder2 = new StringBuilder("aa");

        //链式调用形式
        stringBuilder2.append("aa")//添加数据，返回对象本身
        .append(1)
        .reverse();//反转字符串

        System.out.println(stringBuilder1);//空字符串
        System.out.println(stringBuilder2);//toString已经重写

        String str = stringBuilder2.toString();
        System.out.println(str);

    }
}
